﻿using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Upeu.Matricula.Data.Entities;

namespace Upeu.Matricula.Data.Mappings
{
    public class StudentMap : EntityTypeConfiguration<Student>
    {
        public StudentMap()
        {
            //cambiar nombre table
            ToTable("student");

            //pk
            HasKey(t => t.Id);
            Property(t => t.Id)
                .HasDatabaseGeneratedOption(DatabaseGeneratedOption.Identity);

            //campos
            Property(t => t.Apellidos).IsOptional();
            Property(t => t.CodigoM).IsRequired();
            Property(t => t.Direccion).IsOptional();
            Property(t => t.Nombre).IsRequired();
            Property(t => t.DNI).IsRequired();

            HasRequired(t => t.Tutor)
                .WithMany(t => t.student)
                .HasForeignKey(t => t.Tutor_Id);

        }
    }
}
